<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set scope="request" var="isLogin" value="${ requestScope['javax.servlet.forward.request_uri'].contains('login') }"></c:set>
<c:if test="${ empty title }">
	<c:set scope="request" var="title" value="${ isLogin ? '登录' : '注册' }"></c:set>
</c:if>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>${ title }</title>
    <base href="${ pageContext.servletContext.contextPath }/">
    <link rel="icon" href="statics/img/favicon.svg" sizes="any" type="image/svg+xml">
    <link rel="stylesheet" href="statics/css/base.css">
    <link rel="stylesheet" href="statics/css/form.css">
</head>
<body>
    <%@include file="/pages/common/header.jsp" %>
    <main class="full">
        <h1>欢迎${ title }</h1>
        <form class="login-box" action="user/${ isLogin ? 'login' : 'register' }" method="POST">
            <p class="title">
                <span>${ title }</span>
                <a href="user/${ isLogin ? 'register' : 'login' }">${ isLogin ? '立即注册' : '前往登录' }</a>
            </p>
            <p class="tips ${ empty message ? 'hide' : '' }"> 
                <img src="statics/img/灯泡.png">
                <span>${ message }</span>
            </p>
            <p>用户名称：<input type="text" name="username" value="${ empty username ? cookie.username.value : username }" placeholder="请输入用户名"></p>
            <p>用户密码：<input type="password" name="password" placeholder="请输入密码"></p>
            <c:if test="${ not isLogin }">
            	<p>确认密码：<input type="confirmPassword" name="confirmPassword" placeholder="确认密码"></p>
	            <p>电子邮件：<input type="email" name="email" value="${ email }" placeholder="请输入邮箱地址"></p>
	            <p class="captcha">
	            	验证码：<input type="text" name="code">
	            	<img title="点击切换验证码" src="kaptcha">
	            </p>
            </c:if>
            <p><button class="btn btn-success w-100">${ title }</button></p>
        </form>
    </main>
    <%@include file="/pages/common/footer.jsp" %>

    <script src="statics/js/form.js"></script>
    <script src="statics/js/message_box.js"></script>
    <script src="statics/js/user.js"></script>
</body>
</html>